package com.spring.ai.config;

import com.spring.ai.store.MongoChatMemoryStore;
import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @author: kongmeng
 * @date: 2025/7/17
 * @description:
 *   自定义配置类
 */
@Configuration
public class KongMengAgentConfig {
    @Autowired
    private MongoChatMemoryStore mongoChatMemoryStore;

    @Bean(name = "chatMemoryProviderKongMen")
    public ChatMemoryProvider chatMemoryProviderKongMen(){
         return memoryId-> MessageWindowChatMemory
                 .builder()
                 .id(memoryId)
                 .chatMemoryStore(mongoChatMemoryStore)
                 .maxMessages(20)
                 .build();
    }
}
